 package org.edu.modules.portal.controller;

 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.github.xiaoymin.knife4j.annotations.ApiSort;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import java.util.Arrays;
 import java.util.Map;
 import org.edu.common.api.vo.Result;
 import org.edu.common.aspect.annotation.AutoLog;
 import org.edu.modules.portal.entity.VeSite;
 import org.edu.modules.portal.service.IVeSiteService;
 import org.edu.modules.pub.service.IVeFileImageService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;



 @Api(tags = {"站点信息"})
 @RestController
 @RequestMapping({"/portal/veSite"})
 @ApiSort(10)
 public class VeSiteController
 {
/*  32 */   private static final Logger log = LoggerFactory.getLogger(org.edu.modules.portal.controller.VeSiteController.class);



   @Autowired
   private IVeSiteService veSiteService;


   @Autowired
   private IVeFileImageService veFileImageService;


   @Value("${edu.path.urlPre}")
   private String fileUrlPre;



   @AutoLog("网站信息-通过id查询")
   @ApiOperation(value = "通过id查询(公开)", notes = "网站信息-通过id查询")
   @PostMapping({"/publicInfo/queryById"})
   @ApiOperationSupport(order = 1)
   public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
     Map<String, Object> mapVeSite = this.veSiteService.getMapById(id);
/*  55 */     if (mapVeSite == null) {
/*  56 */       return Result.error("未找到对应数据");
     }
/*  58 */     if (mapVeSite.get("bannerurl") != null) {
/*  59 */       mapVeSite.replace("bannerurl", this.fileUrlPre + mapVeSite.get("bannerurl"));
     }
     if (mapVeSite.get("logourl") != null) {
/*  62 */       mapVeSite.replace("logourl", this.fileUrlPre + mapVeSite.get("logourl"));
     }
     return Result.OK(mapVeSite);
   }













   @AutoLog("网站信息-修改信息")
   @ApiOperation(value = "修改信息", notes = "网站信息-修改信息")
   @PostMapping({"/edit"})
   @ApiOperationSupport(order = 2)
   public Result<?> edit(@RequestBody VeSite veSite) {
     if (veSite.getDomain().equals("")) {
       veSite.setDomain(null);
     }
     if (this.veSiteService.updateById(veSite)) {
       return Result.OK("编辑成功!");
     }
/*  90 */     return Result.error("操作失败");
   }








   @AutoLog("网站信息-通过id删除")
   public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
/* 102 */     this.veSiteService.removeById(id);
     return Result.OK("删除成功!");
   }








   @AutoLog("网站信息-批量删除")
   public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
     this.veSiteService.removeByIds(Arrays.asList(ids.split(",")));
     return Result.OK("批量删除成功!");
   }
 }


